<?php

/*
    [GRIRMS] (C) 2009 Grandison & JM Technologies

    @author kevin<hasson.lai@mobile-grandison.com>
    @version $Id: db.func.php 2010-09-21 kevin $
*/

if(!defined('IN_GRIRMS')) {
	exit('Access Denied');
}

//根据用户ID获取用户名字
function get_username($id){
	global $db;
	$sql="select name from user where id='{$id}'";
	$name = $db->result_first($sql);
	return $name;
}

//根据用户ID获取用户名字
function get_dealer_id($id){
	global $db;
	$sql="select id from user_dealer where user_id='{$id}'";
	$dealer_id = $db->result_first($sql);
	return $dealer_id;
}

//根据region_id获取region_name
function get_region_name($id){
	global $region_list;
	return $region_list[$id]['name'];
}

/* 取得获取记录总数SQL */
function get_count_sql($sql){
	return preg_replace('/^(select)(.*?)( from)/is', '\1 COUNT(*) \3', $sql);
}

?>
